package com.scau402.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.scau402.common.annotation.Log;
import com.scau402.common.core.controller.BaseController;
import com.scau402.common.core.domain.AjaxResult;
import com.scau402.common.enums.BusinessType;
import com.scau402.system.domain.WmsStreamScheduleOrder;
import com.scau402.system.service.IWmsStreamScheduleOrderService;
import com.scau402.common.utils.poi.ExcelUtil;
import com.scau402.common.core.page.TableDataInfo;

/**
 * 排班出库关联表Controller
 * 
 * @author ruoyi
 * @date 2023-06-26
 */
@RestController
@RequestMapping("/system/streamScheduleOrder")
public class WmsStreamScheduleOrderController extends BaseController
{
    @Autowired
    private IWmsStreamScheduleOrderService wmsStreamScheduleOrderService;

    /**
     * 查询排班出库关联表列表
     */
    @PreAuthorize("@ss.hasPermi('system:streamScheduleOrder:list')")
    @GetMapping("/list")
    public TableDataInfo list(WmsStreamScheduleOrder wmsStreamScheduleOrder)
    {
        startPage();
        List<WmsStreamScheduleOrder> list = wmsStreamScheduleOrderService.selectWmsStreamScheduleOrderList(wmsStreamScheduleOrder);
        return getDataTable(list);
    }

    /**
     * 导出排班出库关联表列表
     */
    @PreAuthorize("@ss.hasPermi('system:streamScheduleOrder:export')")
    @Log(title = "排班出库关联表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WmsStreamScheduleOrder wmsStreamScheduleOrder)
    {
        List<WmsStreamScheduleOrder> list = wmsStreamScheduleOrderService.selectWmsStreamScheduleOrderList(wmsStreamScheduleOrder);
        ExcelUtil<WmsStreamScheduleOrder> util = new ExcelUtil<WmsStreamScheduleOrder>(WmsStreamScheduleOrder.class);
        util.exportExcel(response, list, "排班出库关联表数据");
    }

    /**
     * 获取排班出库关联表详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:streamScheduleOrder:query')")
    @GetMapping(value = "/{scheduleId}")
    public AjaxResult getInfo(@PathVariable("scheduleId") Long scheduleId)
    {
        return success(wmsStreamScheduleOrderService.selectWmsStreamScheduleOrderByScheduleId(scheduleId));
    }

    /**
     * 新增排班出库关联表
     */
    @PreAuthorize("@ss.hasPermi('system:streamScheduleOrder:add')")
    @Log(title = "排班出库关联表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WmsStreamScheduleOrder wmsStreamScheduleOrder)
    {
        wmsStreamScheduleOrder.setCreateBy(getUsername());
        return toAjax(wmsStreamScheduleOrderService.insertWmsStreamScheduleOrder(wmsStreamScheduleOrder));
    }

    /**
     * 修改排班出库关联表
     */
    @PreAuthorize("@ss.hasPermi('system:streamScheduleOrder:edit')")
    @Log(title = "排班出库关联表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WmsStreamScheduleOrder wmsStreamScheduleOrder)
    {
        return toAjax(wmsStreamScheduleOrderService.updateWmsStreamScheduleOrder(wmsStreamScheduleOrder));
    }

    /**
     * 删除排班出库关联表
     */
    @PreAuthorize("@ss.hasPermi('system:streamScheduleOrder:remove')")
    @Log(title = "排班出库关联表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{scheduleIds}")
    public AjaxResult remove(@PathVariable Long[] scheduleIds)
    {
        return toAjax(wmsStreamScheduleOrderService.deleteWmsStreamScheduleOrderByScheduleIds(scheduleIds));
    }
}
